#include <stdio.h>
#include <stdlib.h>

// Define a class-like structure using macros
#define CLASS(Name) \
    struct Name {    \
        int data;    \
        void (*print)(struct Name*); \
    }; \

// Define constructor for the "class"
#define CONSTRUCTOR(Name, value) \
    struct Name* Name##_create() { \
        struct Name* obj = (struct Name*)malloc(sizeof(struct Name)); \
        obj->data = value; \
        obj->print = Name##_print; \
        return obj; \
    } \

// Define a method for the "class"
#define METHOD(Name, method_body) \
    void Name##_print(struct Name* self) { \
        method_body \
    } \

int main() {
    // Define multiple classes
    CLASS(ClassA);
    CLASS(ClassB);

    // Define constructors for the classes
    CONSTRUCTOR(ClassA, 42);
    CONSTRUCTOR(ClassB, 123);

    // Define methods for ClassA and ClassB
    METHOD(ClassA, {
        printf("ClassA Data: %d\n", self->data);
    });

    METHOD(ClassB, {
        printf("ClassB Data: %d\n", self->data);
    });

    // Create instances of ClassA and ClassB
    struct ClassA* objA = ClassA_create();
    struct ClassB* objB = ClassB_create();

    // Call the methods
    objA->print(objA);
    objB->print(objB);

    // Clean up
    free(objA);
    free(objB);

    return 0;
}